package com.ocm.core.service;

import java.util.List;
import java.util.Map;

import javax.jcr.Node;
import javax.jcr.Session;

import com.ocm.core.domain.PropertyDefinition;
import com.ocm.core.model.ClassInstance;

public interface JCRService {

   Session login(String username, String password, String connectionURL) throws Exception;

   void logout(Session session) throws Exception;

   Node getNodeId(Session session, String nodeId) throws Exception;

   Node addNode(Session session, String nodeName) throws Exception;

   void updateSecurity(Session session, String nodeId, String securityObject) throws Exception;

   void updateSecurityHasVersionable(Session session, String nodeId, String securityObject) throws Exception;

   Node addNode(Session session, String nodeId, String nodeName, Map<String, Object> properties) throws Exception;

   Map<PropertyDefinition, Object> getValues(Node node, List<PropertyDefinition> properties) throws Exception;
   
   Object getPropertyValue(Session session, String nodeId, PropertyDefinition propertyDefinition) throws Exception;

   void updateNode(Session session, String nodeId, Map<String, Object> properties) throws Exception;

   Node addNodeHasVersion(Session session, String nodeId, String nodeName, Map<String, Object> properties) throws Exception;

   Map<PropertyDefinition, Object> getValues(Session session, String nodeId, List<PropertyDefinition> properties) throws Exception;

   ClassInstance getClassInstance(Session session, String nodeId, List<PropertyDefinition> properties, boolean hasSecurity) throws Exception;

   void removeNode(Session session, String nodeId) throws Exception;

   void removeNodeByPath(Session session, String nodePath) throws Exception;

   void checkout(Session session, String nodeId) throws Exception;

   void checkin(Session session, String nodeId, Map<String, Object> properties) throws Exception;

   void cancelCheckout(Session session, String nodeId) throws Exception;

   void removeLastVersion(Session session, String nodeId) throws Exception;

   List<Map<PropertyDefinition, Object>> historyNode(Session session, String nodeId, List<PropertyDefinition> properties) throws Exception;
}
